<template>
	<div class="page-wrap">
		<div class="page-content p-0">
			<div class="page-column p-0">
				<div class="page-form p-x-0">
					<el-form
						:model="ruleForm"
						:rules="rules"
						label-position="left"
						label-width="140px"
						ref="form"
						label-suffix="："
					>
						<el-row>
							<el-col :span="12">
								<el-form-item label="是否跳过长期模块" prop="MIENDAT2001">
									<select-para
										style="width:100%"
										size="medium"
										class="mediumForm"
										v-model="ruleForm.MIENDAT2001"
										:label.sync="ruleForm.MIENDAT2001"
										:options="MIENDAT2001options"
									></select-para>
								</el-form-item>
							</el-col>
						</el-row>
					</el-form>
				</div>
				<div class="bottom-btn">
					<el-button type="primary" :disabled="this.basic_Data.OCENDAT1001=='TRUE'" :loading="loading" @click="submitFun">下一步</el-button>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
import selectPara from "@/components/selectPara"

import { selecttext } from "@/utils/verify.js"
import { mapState } from "vuex"

export default {
	name: "aboutUs",
	props: {
		basicDataF: Object,
	},
	components: {
		selectPara,
	},

	data() {
		return {
			activeTab: "2",
			ruleForm: {
				MIENDAT2001: "FALSE",
			},
			rules: {
				MIENDAT2001: [
					{
						validator: selecttext,
						trigger: ["change", "blur"],
					},
				],
			},
			loading: false,
			MIENDAT2001options: [
				{
					label: "TRUE",
					value: "TRUE",
				},
				{
					label: "FALSE",
					value: "FALSE",
				},
			],
		}
	},
	computed: {
		...mapState({
			early_Data: (state) => state.token.early_Data,
			basic_Data: (state) => state.token.basic_Data,
		}),
	},
	mounted() {
		this.getData()
	},
	methods: {
		getData(){ 
			this.ruleForm.MIENDAT2001=this.early_Data.MIENDAT2001?this.early_Data.MIENDAT2001:'FALSE'
		},
		submitFun() {
			//保存
			this.$refs.form.validate((valid) => {
				if (valid) {
					this.$notify({
						message: "保存成功！",
						type: "success",
					}) 
					let tempdata = JSON.parse(JSON.stringify(this.early_Data)) 
					tempdata.MIENDAT2001 = this.ruleForm.MIENDAT2001
					tempdata.SETPAGEINDEX = this.activeTab
					this.$store.dispatch("upData_early_Data", tempdata) 
					let params = {
						batchid: this.$route.query.id,
						batchinfo: "ZAOQI",
						submitjson: JSON.stringify(tempdata),
					} 
					this.$appApi
						.BATCH_SUBMIT(params)
						.then((res) => { 
							var str = res.data.substring(0, 1)
							if (str == "E") {
								let message = res.data.substring(6)
								this.$notify.error({
									title: "提交失败！",
									message: message,
									type: "success",
								})
							} else if (str == "S") {
								this.$notify({
									message: "提交成功！",
									type: "success",
								})
							}
						})
						.catch((err) => {
							console.log(err)
						})
					this.$emit("changeActiveTab", this.activeTab)
					this.$store.dispatch("change_early_showTab", this.activeTab)
				}
			})
		},
	},
}
</script>
<style lang="scss" scoped>
.page-flex-row /deep/ .el-collapse-item__header {
	background: #f3f9fe;
}
</style>